﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SalePartial.IDAL;
using System.Data.SqlClient;
using SalePartial.Model;
using System.Data;

namespace SalePartial.BLL
{
    public class XPNews : IXPNews
    {
        private IXPNews dal = SalePartial.DALFactory.DataAccess.CreateXPNews();

        public void Delete(XPNewsInfo newsInfo)
        {
            dal.Delete(newsInfo.NewsID);
        }

        public XPNewsInfo GetXPNews(Guid id)
        {
            SqlDataReader reader = this.SelectReader(id);
            if (reader.Read())
            {
                XPNewsInfo info = new XPNewsInfo(reader);
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
            
                return info;
            }
            return null;

        }


        public int Delete(Guid CompanyID)
        {
            return dal.Delete(CompanyID);
        }

        public int DeleteDynamic(string v_whereCondition)
        {
            return dal.DeleteDynamic(v_whereCondition);
        }

        public int Insert(XPNewsInfo info)
        {
            return dal.Insert(info);
        }

        public System.Data.DataSet SelectAll()
        {
            return dal.SelectAll();
        }

        public XPNewsInfo SelectByNewsID(Guid NewsID)
        {
            return dal.SelectByNewsID(NewsID);
        }

        public SqlDataReader SelectByCateGoryID(Guid CaID)
        {
            return dal.SelectByCateGoryID(CaID);
        }


        public System.Data.DataSet SelectDynamic(string v_whereCondition, string v_orderByExpression)
        {
            return dal.SelectDynamic(v_whereCondition, v_orderByExpression);
        }

        public System.Data.DataSet SelectPaged()
        {
            return dal.SelectPaged();
        }

        public System.Data.SqlClient.SqlDataReader SelectReader(Guid CompanyID)
        {
            return dal.SelectReader(CompanyID);
        }

        public int Update(XPNewsInfo info)
        {
            return dal.Update(info);
        }

        public DataSet SelectTop10News()
        {
            return null;
        }

        public DataSet SelectHotNews()
        {
            return null;
        }
    }

}
